using System;
using System.ServiceProcess;

namespace TripleA.Core.Extensions.WindowsService
{
    /// <summary>
    /// This asserts the windows service has the expected startmode
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class WindowsServiceStartModeStep<T> : WindowsServiceWmiStepBase<T>
    {
        public ServiceStartMode StartMode { get; set; }

        protected override void InspectService(ServiceInfo service)
        {
            if (!StartMode.ToString().StartsWith(service.StartMode))
                throw new ApplicationException(string.Format("Service '{0}' on '{1}' expected startmode is '{2}', actual '{3}'",
                        ServiceName, Machine, StartMode, service.StartMode));
        }
    }
}